home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Game Programming Gurus / Tricks of the Windows Game Programming Gurus (SAMS)(2000).iso / Goodies / t3dlib3.h < prev   
C/C++ Source or Header  |  1999-04-15  |  4KB  |  120 lines

  1. // T3DLIB3.H - Header file for T3DLIB3.CPP game engine library
  2.  
  3. // watch for multiple inclusions
  4. #ifndef T3DLIB3
  5. #define T3DLIB3
  6.  
  7. // DEFINES ////////////////////////////////////////////////
  8.  
  9.  
  10. #define DM_NUM_SEGMENTS 64 // number of midi segments that can be cached in memory
  11.  
  12. // midi object state defines
  13. #define MIDI_NULL     0   // this midi object is not loaded
  14. #define MIDI_LOADED   1   // this midi object is loaded
  15. #define MIDI_PLAYING  2   // this midi object is loaded and playing
  16. #define MIDI_STOPPED  3   // this midi object is loaded, but stopped
  17.  
  18.  
  19. #define MAX_SOUNDS     256 // max number of sounds in system at once 
  20.  
  21. // digital sound object state defines
  22. #define SOUND_NULL     0 // " "
  23. #define SOUND_LOADED   1
  24. #define SOUND_PLAYING  2
  25. #define SOUND_STOPPED  3
  26.  
  27. // MACROS /////////////////////////////////////////////////
  28.  
  29. #define DSVOLUME_TO_DB(volume) ((DWORD)(-30*(100 - volume)))
  30.  
  31. // Convert from multibyte format to Unicode using the following macro:
  32. #define MULTI_TO_WIDE( x,y )  MultiByteToWideChar( CP_ACP,MB_PRECOMPOSED, y,-1,x,_MAX_PATH);
  33.  
  34. // initializes a direct draw struct
  35. #define DD_INIT_STRUCT(ddstruct) { memset(&ddstruct,0,sizeof(ddstruct)); ddstruct.dwSize=sizeof(ddstruct); }
  36.  
  37.  
  38. // TYPES //////////////////////////////////////////////////
  39.  
  40. // this holds a single sound
  41. typedef struct pcm_sound_typ
  42.     {
  43.     LPDIRECTSOUNDBUFFER dsbuffer;   // the ds buffer containing the sound
  44.     int state;                      // state of the sound
  45.     int rate;                       // playback rate
  46.     int size;                       // size of sound
  47.     int id;                         // id number of the sound
  48.     } pcm_sound, *pcm_sound_ptr;
  49.  
  50. // directmusic MIDI segment
  51. typedef struct DMUSIC_MIDI_TYP
  52. {
  53. IDirectMusicSegment        *dm_segment;  // the directmusic segment
  54. IDirectMusicSegmentState   *dm_segstate; // the state of the segment
  55. int                        id;           // the id of this segment               
  56. int                        state;        // state of midi song
  57.  
  58. } DMUSIC_MIDI, *DMUSIC_MIDI_PTR;
  59.  
  60.  
  61. // PROTOTYPES /////////////////////////////////////////////
  62.  
  63. // directsound
  64. int DSound_Load_WAV(char *filename, int control_flags = DSBCAPS_CTRLDEFAULT);
  65. int DSound_Replicate_Sound(int source_id);
  66. int DSound_Play(int id, int flags=0, int volume=0, int rate=0, int pan=0);
  67. int DSound_Stop_Sound(int id);
  68. int DSound_Stop_All_Sounds(void);
  69. int DSound_Init(void);
  70. int DSound_Shutdown(void);
  71. int DSound_Delete_Sound(int id);
  72. int DSound_Delete_All_Sounds(void);
  73. int DSound_Status_Sound(int id);
  74. int DSound_Set_Volume(int id,int vol);
  75. int DSound_Set_Freq(int id,int freq);
  76. int DSound_Set_Pan(int id,int pan);
  77.  
  78. // directmusic
  79. int DMusic_Load_MIDI(char *filename);
  80. int DMusic_Play(int id);
  81. int DMusic_Stop(int id);
  82. int DMusic_Shutdown(void);
  83. int DMusic_Delete_MIDI(int id);
  84. int DMusic_Delete_All_MIDI(void);
  85. int DMusic_Status_MIDI(int id);
  86. int DMusic_Init(void);
  87.  
  88. // directmusic
  89.  
  90. // GLOBALS ////////////////////////////////////////////////
  91.  
  92.  
  93. // EXTERNALS //////////////////////////////////////////////
  94.  
  95. extern HWND main_window_handle; // save the window handle
  96. extern HINSTANCE main_instance; // save the instance
  97.  
  98. extern LPDIRECTSOUND        lpds;           // directsound interface pointer
  99. extern DSBUFFERDESC            dsbd;           // directsound description
  100. extern DSCAPS                dscaps;         // directsound caps
  101. extern HRESULT                dsresult;       // general directsound result
  102. extern DSBCAPS                dsbcaps;        // directsound buffer caps
  103.  
  104. extern LPDIRECTSOUNDBUFFER    lpdsbprimary;   // the primary mixing buffer
  105. extern pcm_sound            sound_fx[MAX_SOUNDS];    // the array of secondary sound buffers
  106.  
  107. extern WAVEFORMATEX            pcmwf;          // generic waveformat structure
  108.  
  109. // direct music globals
  110. extern IDirectMusicPerformance    *dm_perf ;    // the directmusic performance manager 
  111. extern IDirectMusicLoader         *dm_loader;  // the directmusic loader
  112.  
  113. // this hold all the directmusic midi objects
  114. extern DMUSIC_MIDI                dm_midi[DM_NUM_SEGMENTS];
  115. extern int dm_active_id;                               // currently active midi segment
  116.  
  117. #endif
  118.  
  119.  
  120.